{
  "properties" : { },
  "id" : "f76d7d01d17e4ac2a9ed455ede3f7d30",
  "script" : null,
  "groupId" : "6a869ffd71b240c6a1576faddb094650",
  "name" : "提取图片",
  "createTime" : null,
  "updateTime" : 1741279237660,
  "lock" : null,
  "createBy" : null,
  "updateBy" : "管理员",
  "path" : "tqtp",
  "method" : "GET",
  "parameters" : [ ],
  "options" : [ ],
  "requestBody" : "",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : "{\n    \"code\": 200,\n    \"msg\": \"success\",\n    \"data\": \"Hello magic-api\"\n}",
  "description" : null,
  "requestBodyDefinition" : null,
  "responseBodyDefinition" : null
}
================================
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.Base64;

String mhtFilePath = "F:/file/离线网页/xx/xxxxxxxxxxxxxxxxxxxxx.mht";
Path outputDir = Paths.get("F:/file/离线网页/xx/xxxxxxxxxxxxxxxxxxxxx");

Files.createDirectories(outputDir);

// 读取.mht文件内容
String content = new String(Files.readAllBytes(Paths.get(mhtFilePath)));
// 定义正则表达式来匹配base64编码的图片
Pattern pattern = Pattern.compile(
    "Content-Type:\\s*image/(\\w+)\\s*" + // 匹配图片类型
    "Content-Transfer-Encoding:\\s*base64\\s*" + // 匹配编码方式为base64
    "(?:Content-Location:[^\\r\\n]*\\r?\\n)?\\r?\\n" + // 可选的Content-Location行
    "([\\s\\S]*?)" + // 捕获任意数量的字符直到遇到下一个边界或结束
    "--?(?=\\s*--|\\z)", // 边界结束符或者文件结束
    Pattern.DOTALL | Pattern.CASE_INSENSITIVE
);

Matcher matcher = pattern.matcher(content);
int index = 0;
while (matcher.find()) {
    String ContentLocation = matcher.group(0).split('\r\n')[2];
    String HttpUrl = ContentLocation.substring(ContentLocation.lastIndexOf(': ') + 1).trim();
    String fileName = HttpUrl.substring(HttpUrl.lastIndexOf('/') + 1);

    String type = matcher.group(1); // 图片类型, 比如 png, jpg 等
    String base64Image = matcher.group(2).trim(); // Base64编码的字符串

    // 如果 Content-Location 包含 /themes/ 则跳过此部分
    if (HttpUrl.contains("/themes/") || HttpUrl.contains("/game/") 
        || HttpUrl.endsWith(".php") || HttpUrl.contains("%")) {
        continue;
    }

    // 创建输出文件路径
    Path outputPath = outputDir.resolve(fileName);

    // 将解码后的图片写入文件
    Files.write(outputPath, Base64.getMimeDecoder().decode(base64Image));
}


return true